/*
 * File: MouseCordinates.cs
 * Author: Gourav Das
 * Purpose: Displays Mouse Cordinates
 * Created: April 30th 2011
 * Copyright: Gourav Das, 2011
 */

using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace _22yards.Helpers
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class MouseCordinates : DrawableGameComponent
    {
        ContentManager content;
        SpriteBatch spriteBatch;
        SpriteFont spriteFont;

        /// <summary>
        /// Initializes a new instance of the <see cref="FrameRateCounter"/> class.
        /// </summary>
        /// <param name="game">The Game that the game component should be attached to.</param>
        public MouseCordinates(Game game)
            : base(game)
        {
            content = new ContentManager(game.Services, "22yardsContent");
        }


        /// <summary>
        /// Called when graphics resources need to be loaded. Override this method to load any component-specific graphics resources.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            spriteFont = content.Load<SpriteFont>("Helpers/Fonts/FPSFont");
        }


        /// <summary>
        /// Called when graphics resources need to be unloaded. Override this method to unload any component-specific graphics resources.
        /// </summary>
        protected override void UnloadContent()
        {
            content.Unload();
        }


        /// <summary>
        /// Called when the DrawableGameComponent needs to be drawn. Override this method with component-specific drawing code. Reference page contains links to related conceptual articles.
        /// </summary>
        /// <param name="gameTime">Time passed since the last call to Draw.</param>
        public override void Draw(GameTime gameTime)
        {
            spriteBatch.Begin();

            //Displays Mouse Co ordinates
            try
            {
                spriteBatch.DrawString(spriteFont, "X: " + Mouse.GetState().X, new Vector2(33, 56), Color.Black, 0f, Vector2.Zero, 0.9f, SpriteEffects.None, 0);
                spriteBatch.DrawString(spriteFont, "X: " + Mouse.GetState().X, new Vector2(32, 55), Color.White, 0f, Vector2.Zero, 0.9f, SpriteEffects.None, 0);
                spriteBatch.DrawString(spriteFont, "Y: " + Mouse.GetState().Y, new Vector2(33, 73), Color.Black, 0f, Vector2.Zero, 0.9f, SpriteEffects.None, 0);
                spriteBatch.DrawString(spriteFont, "Y: " + Mouse.GetState().Y, new Vector2(32, 72), Color.White, 0f, Vector2.Zero, 0.9f, SpriteEffects.None, 0);
            }
            catch
            {

            }
            spriteBatch.End();
        }
    }
}
